using System;
using System.Collections.Generic;
using System.Text;

namespace Objects
{
    public class KhachHang
    {
        #region KhachHang variables

        private int _Id;
        private String _Ten;
        private String _GioiTinh;
        private String _CMND;
        private DateTime _NgaySinh;
        private DateTime _NgayCap;
        private String _DiaChiThuongTru;
        private String _DiaChiLienLac;
        private String _DienThoaiNha;
        private String _DienThoaiDiDong;
        private String _GhiChu;
        private String _Email;

        private int _Status;
        private int _SapXep;

        private int _IdTinhThanh;
        private int _IdQuoctich;

        #endregion

        #region KhachHang properties

        public int Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        public String Ten
        {
            get { return _Ten; }
            set { _Ten = value; }
        }

        public String GioiTinh
        {
            get { return _GioiTinh; }
            set { _GioiTinh = value; }
        }

        public DateTime NgaySinh
        {
            get { return _NgaySinh; }
            set { _NgaySinh = value; }
        }

        public DateTime NgayCap
        {
            get { return _NgayCap; }
            set { _NgayCap = value; }
        }

        public String CMND
        {
            get { return _CMND; }
            set { _CMND = value; }
        }

        public String DiaChiThuongTru
        {
            get { return _DiaChiThuongTru; }
            set { _DiaChiThuongTru = value; }
        }

        public String DiaChiLienLac
        {
            get { return _DiaChiLienLac; }
            set { _DiaChiLienLac = value; }
        }

        public String Email
        {
            get { return _Email; }
            set { _Email = value; }
        }

        public String DienThoaiNha
        {
            get { return _DienThoaiNha; }
            set { _DienThoaiNha = value; }
        }

        public String DienThoaiDiDong
        {
            get { return _DienThoaiDiDong; }
            set { _DienThoaiDiDong = value; }
        }

        public String GhiChu
        {
            get { return _GhiChu; }
            set { _GhiChu = value; }
        }

        public int Status
        {
            get { return _Status; }
            set { _Status = value; }
        }

        public int SapXep
        {
            get { return _SapXep; }
            set { _SapXep = value; }
        }

        public int IdQuoctich
        {
            get { return _IdQuoctich; }
            set { _IdQuoctich = value; }
        }

        public int IdTinhThanh
        {
            get { return _IdTinhThanh; }
            set { _IdTinhThanh = value; }
        }

        #endregion

        #region IPopulatable<KhachHang> Members

        public KhachHang Populate(System.Data.DataRow reader)
        {
            KhachHang item = new KhachHang();

            try { item.Id = Convert.ToInt32(reader["Id"].ToString()); }
            catch { item.Id = -1; }

            item.Ten = Convert.ToString(reader["Ten"].ToString());
            item.GioiTinh = Convert.ToString(reader["GioiTinh"].ToString());
            item.CMND = Convert.ToString(reader["CMND"].ToString());

            item.NgaySinh = Convert.ToDateTime(reader["NgaySinh"].ToString());
            item.NgayCap = Convert.ToDateTime(reader["NgayCap"].ToString());

            item.DiaChiLienLac = Convert.ToString(reader["DiaChiLienLac"].ToString());
            item.DiaChiThuongTru = Convert.ToString(reader["DiaChiLienLac"].ToString());
            item.DiaChiLienLac = Convert.ToString(reader["DiaChiLienLac"].ToString());
            item.Email = Convert.ToString(reader["Email"].ToString());
            item.DienThoaiNha = Convert.ToString(reader["DienThoaiNha"].ToString());
            item.DienThoaiDiDong = Convert.ToString(reader["DienThoaiDiDong"].ToString());
            item.GhiChu = Convert.ToString(reader["GhiChu"].ToString());

            item.Status = Convert.ToInt32(reader["Status"].ToString());
            item.SapXep = Convert.ToInt32(reader["SapXep"].ToString());

            try { item.IdQuoctich = Convert.ToInt32(reader["IdQuoctich"].ToString()); }
            catch { item.IdQuoctich = -1; }

            try { item.IdTinhThanh = Convert.ToInt32(reader["IdTinhThanh"].ToString()); }
            catch { item.IdTinhThanh = -1; }

            return item;
        }

        #endregion
    }
}
